package com.cg.service.impl;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cg.dao.MapGridDao;
import com.cg.entity.MapGrid;
import com.cg.utils.FilterRule;
import com.cg.utils.FilterRuleBuilder;
import com.cg.utils.R;

@Service
public class MapGridService {

	@Autowired
	private MapGridDao mapGridDao;
	
	
	public List<MapGrid> getAllMapGrid(){
		return mapGridDao.findAll();
	}
	
	public List<MapGrid> getMapGridByIds(Collection<Integer> ids){
		List<FilterRule> filterRules = FilterRuleBuilder.newBuilder().key("id").in().value(ids)
                .build();
		return mapGridDao.findByCondition(filterRules);
	}
	
	public List<MapGrid> getPolygon(){
		List<FilterRule> filterRules = FilterRuleBuilder.newBuilder().key("id").eq().value(1)
                .build();
		return mapGridDao.findPolygonByCondition(filterRules);
	}
	
	
	public List<MapGrid> queryList(Map<String, Object> params){
		
		return mapGridDao.queryList(params);
	}
	
	public R save(MapGrid mapGrid){
		mapGridDao.save(mapGrid);
		return R.ok();
	}
	
	public int queryTotal(Map<String,Object> query) {
		
		return mapGridDao.queryTotal();
	}
	
	public R update(MapGrid search){
		mapGridDao.update(search);
		return R.ok();
	}
	
	public void deleteBatch(Long[] ids) {
		mapGridDao.deleteBatch(ids);
	}

	
	public MapGrid queryObject(Long id) {
		return mapGridDao.queryObject(id);
	}
	
	
}
